var DRIVER = require('selenium-webdriver');
var profile = DRIVER.Capabilities.chrome();
profile.set('browserName', 'chrome');
profile.set('chromeOptions', {
    'args': ['--lang=zh-CN','--disable-plugins','--no-sandbox' ,'--start-maximized', 'test-type', '--disable-popup-blocking', '--user-agent=selenium-webdriver']
});
function open(name, pass) {
    var BUILDER = new DRIVER.Builder().withCapabilities(profile);
    var BROWSER = BUILDER.build();
    BROWSER.get('http://139.196.105.91:3000/resource/course_ware/add_ware?categoryId=1100010008').then(function () {
        BROWSER.executeScript(login.toString() + ";setTimeout(function(){login('" + name + "','" + pass + "')},2000);");
    });
    // BROWSER.wait(function(){
    //     BROWSER.executeScript(form.toString() + ";setTimeout(function(){form('" + name + "','" + pass + "')},2000);");
    // },10000);

    function form(){
        $('#saveForm [name=coursewareName]').val(1);
        $('#saveForm [name=coursewareAuthor]').val(2);
        $('#saveForm [name=coursewareDesc]').val(3);
        $('#saveForm [name=remark]').val(4);
        $('.select2-selection__rendered:eq(1)').click();
        $('[data-nodeid="0"]').click();
        $('[data-nodeid="1"]').click();
        $('[data-nodeid="2"] .glyphicon-unchecked').click();
        $('.select2-selection__rendered:eq(1)').click();

    }
    function login(name, pass) {
        document.forms[0].loginAccount.value = name;
        document.forms[0].password.value = pass;
        $('.loginSubmit').submit();
        setTimeout(form,2000);
    }
}
open('zhongnan_111111','123456');



